package fr.enssat.tpcloud.model;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "tPost")
public class Post {
	
	/**
	 * Identifiant du post
	 */
	//
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false, fetch = FetchType.LAZY) // Quand on demande les posts la Bd ne doit pas nous retourner les user en mm temps
	@Column(name = "idPost")
	private int id;
	
	/**
	 * Message
	 */
	@Column(name = "message")
	private String message;
	
	/**
	 * Date de creation du post
	 */
	@Column(name = "date")
	private Date creationDate;
	
	 /**
     * User ayant ecrit le post
     */
    @JoinColumn(name = "idUser", referencedColumnName = "idUser")
    @ManyToOne(optional = false)
    private User user;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
